<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" href="preview/css/reset.css"/>
    <link rel="stylesheet" href="preview/css/liMarquee.css"/>
    <script src="dragStatic/js/jquery-3.2.1.min.js"></script>
    <script src="preview/js/rem.js"></script>
    <script src="dragStatic/js/common.js"></script>
    <script src="preview/js/jquery.liMarquee.js"></script>
    <title>大数据单模块-名人名言</title>
    <style>

        /*//    名人名言模块 ,*/
        /*$('.famous').css({height:60/1080*h+"px",lineHeight:60/1080*h+"px",width:807/1920*w+"px",marginTop:-80/1080*h+"px",marginLeft:380/1920*w+"px"});*/
        /*$('#famous_title').css({width:"22%"});*/
        /*$('.famous_con').css({width:"75%",color:"#fff"});*/

        .famous{height: 0.6rem;line-height: 0.6rem;}
        .famous .module-title{width:22%;float: left;}
        .famous-content{width: 75%;float:right;color:#fff;font-size:0.22rem;}


    </style>
</head>
<body>
    <div class="famous">
        <div class="module-title ycenterbox"><img src="preview/img/listimg.png" /><span class="section_name" data-key="today_recom_str">名人名言</span></div>
        <div class="famous-content">
            <!--<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;土地是以它的肥沃和收获而被估价的；才能也是土地，不过它生产的不是粮食，而是真理。如果只能滋生瞑想和幻想的话，即使再大的才能也只是砂地或盐池，那上面连小草也长不出来的。 —— 别林斯基&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>-->
        </div>
        <div class="block"></div>
    </div>
</body>
<script>
    window.onload = function(){
        var str="";
        page_init(100,810,"名人名言");
        var gobalAddr="whfw.superlib.com:9025";
//        famous();
        fnt_ws_famous_saying('wss://'+gobalAddr+'/cxts/mobile/ws/famous_saying');//名人名言WebSocket连接
        //名人名言WebSocket连接
        var last_famous_data;
        var websocket_famous_saying;
//最大重连次数
        var max_try_num_famous = 10;
        var curr_try_num_famous = 0;
        function fnt_ws_famous_saying(ws_url){
            websocket_famous_saying=new WebSocket(ws_url);//参数是服务器地址，还有一个参数是自协议可以不写
            websocket_famous_saying.onopen=function(){
                console.log('名人名言连接成功...');
            };
            websocket_famous_saying.onmessage=function(msg){
                var json = JSON.parse(msg.data);
                if (last_famous_data === msg.data){
                    return;
                }
                console.log('名人名言数据更新了...');
                last_famous_data = msg.data;
                str='';
                var blank='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                $.each(json.result,function(i,e){
                    str+=e.famous_saying+'<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>------'+e.famous_name+'<span>'+blank+'</span>';
                });
                $('.famous-content').html(str);
                $('.famous-content').liMarquee({scrollamount: 30});///名人名言动效，数字越小速度越慢
                divFlex("famous");////调用缩放功能

            };
            websocket_famous_saying.onclose=function(){
                if (curr_try_num_famous <= max_try_num_famous) {
                    console.log("名人名言连接关闭，6秒后重新连接...");
                    setTimeout(function () {
                        fnt_ws_famous_saying(ws_url);
                    }, 6000);
                } else {
                    console.log("名人名言连接超过最大重连次数，不再重连...");
                }
            };
            websocket_famous_saying.onerror = function (err) {
                console.log('名人名言连接发生错误...');
            };
        }
        window.onresize = function(){
            page_init(100,810,"名人名言");
            $('.famous-content').html(" ");
            $('.famous-content').html(str);
            $('.famous-content').liMarquee({scrollamount: 30});///名人名言动效，数字越小速度越慢
        };

    }

//    function famous(){
//        $.ajax({
//            type: "get",
//            url: "https://"+gobalAddr+"/cxts/famousSaying/lookUp",
//            dataType: "json",
//            data: {},
//            success: function (json) {
//                //var str=json.result[0].famous_saying+'              ------'+json.result[0].famous_name;
//                //$('.famous_con').html(str);
//                //$('.famous_con').liMarquee({scrollamount: 30});///名人名言动效，数字越小速度越慢
//                var str='',blank='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
//                $.each(json.result,function(i,e){
//                    str+=e.famous_saying+'<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>------'+e.famous_name+'<span>'+blank+'</span>';
//                });
//                $('.famous-content').html(str);
//                $('.famous-content').liMarquee({scrollamount: 30});///名人名言动效，数字越小速度越慢
//                divFlex("famous");////调用缩放功能
//
//            }
//        });
//    }

</script>
</html>